<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        html,body{
            width: 100%;
            height: 100%;
            text-align: center;
            overflow: hidden;
        }
        #box{
            position: absolute;
            top: 0px;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            z-index: 9;
            display: none;
        }
        #btn{
           top: 10px;
            position: absolute;
            cursor: pointer;
            
        }
        .content{
            width: 300px;
            height: 200px;
            border: 5px solid orangered;
            position: absolute;
            top: 50%;
            margin-top: -100px;          
            left: 50%;
            margin-left: -150px;
            background-color: white;
        }
        .yellow{
            width: 100%;
            height: 30px;
            border-bottom: 5px solid orangered;
            background-color: orange;
           
        }
        .yellow button{
            float: right;
          margin-top: 5px;
          cursor: pointer;
        }
    </style>
</head>
<body>
    <div id="box">
        <div class="content">
            <div class="yellow"><button id="del">X</button></div>
        </div>
    </div>
    <button id="btn">弹出层</button>
</body>
<script>
    var btn = document.getElementById('btn')
    var box = document.getElementById('box')
    var dle = document.getElementById('del')
    btn.onclick = function(){
        box.style.display = 'block'
    }
    del.onclick = function(){
        box.style.display = 'none'
    }
</script>
</html>